<template>
	<!-- 设置页面 -->
	<view class="set-up-page">
		<view class="list">
			<view class="list-item">
				<view class="item-left">
					<view class="item-title">消息通知</view>
					<view class="item-detail">关闭后，将无法收创精彩内宏推送、问答回复等消息通知</view>
				</view>
				<view class="item-right">
					<switch />
				</view>
			</view>
		</view>

		<view class="list">
			<view class="list-item">
				<view class="item-left">
					<view class="item-title">清理缓存</view>
				</view>
				<view class="item-right">
					<view class="right-text">0KB</view>
				</view>
			</view>
			<view class="h-line"/>
			<view class="list-item">
				<view class="item-left">
					<view class="item-title">检查更新</view>
				</view>
				<view class="item-right">
					<view class="right-text">{{version}}</view>
				</view>
			</view>
			<view class="h-line"/>
			<view class="list-item" @click="toAboutUs">
				<view class="item-left">
					<view class="item-title">关于我们</view>
				</view>
				<view class="item-right">
					<view class="slw-icon">&#xe733;</view>
				</view>
			</view>
			<view class="h-line"/>
			<view class="list-item" @click="toUserAgreement">
				<view class="item-left">
					<view class="item-title">用户条款</view>
				</view>
				<view class="item-right">
					<view class="slw-icon">&#xe733;</view>
				</view>
			</view>
			<!-- <view class="h-line"/>
			<view class="list-item" @click="toPrivacyAgreement">
				<view class="item-left">
					<view class="item-title">隐私协议</view>
				</view>
				<view class="item-right">
					<view class="slw-icon">&#xe733;</view>
				</view>
			</view> -->
		</view>
		
		<view class="list">
			<view v-if="isLogin" class="list-item" @click="onSignOut">
				<view class="item-left">
					<view class="item-title">退出登录</view>
				</view>
				<view class="item-right">
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {removeLoginInfo, verifyUserLogin} from '@/utils/storage.js'
	import { version } from '@/config/index.js'
	import {toUserPage, toAboutUs, toUserAgreement, toPrivacyAgreement} from '@/utils/PageRouter.js'
	export default {
		data() {
			return {
				isLogin: false,
				version: version
			}
		},
		onShow () {
			verifyUserLogin().then(() => {
				this.isLogin = true
			}).catch(e => {
				this.isLogin = false
			})
		},
		methods: {
			onSignOut () {
				getApp().globalData.isAccount=false
				uni.showLoading({title: '加载中...'})
				removeLoginInfo()
				setTimeout(() => {
					uni.hideLoading()
					toUserPage()
				}, 2000)
			},
			toAboutUs() {
				toAboutUs()
			},
			toUserAgreement() {
				toUserAgreement()
			},
			toPrivacyAgreement() {
				toPrivacyAgreement()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.set-up-page{
		.list{
			padding: 0 30rpx;
			background: #fff;
			margin-bottom: 20rpx;
			&:last-child{margin-bottom: 0;}
			.list-item{
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				&:last-child{
					border-bottom: none;
				}
				.item-left{
					.item-title{
						
					}
					.item-detail{
						color: #999;
						font-size: 20rpx;
					}
				}
				.item-right{
					
				}
			}
		}
		.list /deep/{
			//	原生开关样式重载
			.uni-switch-wrapper{
				.uni-switch-input{
					width: 80rpx;
					height: 40rpx;
					border-width: 4rpx;
					margin-right: 0;
					&:after{
						width: 32rpx;
						height: 32rpx;
					}
					&:before{
						display: none;
					}
				}
				.uni-switch-input.uni-switch-input-checked:after{
					transform: translateX(40rpx);
				}
			}
		}
	}
</style>
